﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CSharpAlgorithm
{
    class LetterBank
    {
        public LetterBank()
        {
            int testCase = GetConsole.GetInt();
            
            while (testCase-- > 0)
            {
                string a = GetConsole.GetString();
                string b = GetConsole.GetString();
                int[] alphabet = new int[26];
                bool check = true;
				//첫번째 단어를 1로 세팅
                for (int i = 0; i < a.Length; i++)
                {
                    int alphabetIndex = a[i] - 65;
                    alphabet[alphabetIndex] = 1;
                }
				//두번째 단어가 포함되는지 확인. 포함되면 +1
                for (int i = 0; i < b.Length; i++)
                {
                    int alphabetIndex = b[i] - 65;
                    if (alphabet[alphabetIndex] > 0)
                    {
                        alphabet[alphabetIndex]++;
                    }
                    else
                    {
                        check = false;
                        Console.WriteLine("NO");
                        break;
                    }
                }
				//누락된 글자가 없는지 확인
                if (check)
                {
                    for (int i = 0; i < a.Length; i++)
                    {
                        int alphabetIndex = a[i] - 65;
                        if (alphabet[alphabetIndex] <= 1)
                        {
                            check = false;
                            Console.WriteLine("NO");
                            break;
                        }
                    }
                    if (check)
                    {
                        Console.WriteLine("YES");
                    }
                }
            }
        }
    }
}
